<?php
class SavedPostGetter {

public $posts = null;

function __construct() {

  $this->posts = array();
  $link = mysql_connect('localhost', 'root', '');
  if (!$link) {
    die('Not connected : ' . mysql_error());
  }

  // make foo the current FinalProject
  $db_selected = mysql_select_db('FinalProject', $link);
  if (!$db_selected) {
    die ('Can\'t use Final Project: ' . mysql_error());
  }
  
		  // Formulate Query
          // This is the best way to perform an SQL query
          // For more examples, see mysql_real_escape_string()
		  $user= $_COOKIE["usr"];
          $query = sprintf("SELECT * FROM `%s` WHERE 1=1",
              mysql_real_escape_string($user));

          // Perform Query
          $result = mysql_query($query);

          // Check result
          // This shows the actual query sent to MySQL, and the error. Useful for debugging.
          if (!$result) {
                 $message  = 'Invalid query: '.mysql_error().' ';
                 $message .= 'Whole query: '.$query;
                 die($message);
          }
			$i =0;
		   while ($row = mysql_fetch_assoc($result)) {
				$this->posts[$i] = $row;
				$i++;
		   }
}
}
?>